package com.mew.slots.core.game.hrljj.room;

import cn.hutool.core.util.RandomUtil;
import com.mew.slots.core.common.game.BaseRoom;
import com.mew.slots.core.game.hrljj.bo.HrljjPlayMsgs;
import com.mew.slots.core.game.hrljj.roller.Controlline;

import java.util.ArrayList;

public class HrljjRoom extends BaseRoom {

    final int _SCATTER = 13;
    final int _BONUS = 12;
    public HrljjRoom(){
        res = new HrljjPlayMsgs();
        row = 3;
        col = 5;
        _WILD = 11;
        spes = new ArrayList<Integer>(){{
            add(_SCATTER);
            add(_BONUS);
        }};
        rate = new int[][]{
                {0, 0,  5, 15, 50},      //方块          0
                {0, 0,  5, 15, 50},      //梅花           1
                {0, 0,  5, 15, 50},      //红桃           2
                {0, 0,  5, 15, 50},       //黑桃           3
                {0, 0,  5, 15, 50},      //藏宝图          4
                {0, 0,  5, 15, 50},     //仙人掌          5

                {0, 0, 10, 25, 100},      //红毛猫          6
                {0, 0, 10, 30, 150},      //黄毛猫          7
                {0, 0, 10, 30, 150},     //灰猫            8
                {0, 0, 10, 30, 150},      //黑猫            9
                {0, 5, 15, 50, 300},      //傻逼帽子猫       10

                {0, 0,  0,   0,  0},      //WILD            11
                {0, 0,  0,   0,  0},      //BONUS 帽子       12
                {0, 0,  0,   0,  0},      // SCATTER         13
        };
        alllines=new int[][]{
                {5,6,7,8,9},
                {0,1,2,3,4},
                {10,11,12,13,14},
                {0,6,12,8,4},
                {10,6,2,8,14},
                {5,1,7,13,9},
                {5,11,7,3,9},
                {0,1,7,13,14},
                {10,11,7,3,4},
                {0,6,2,8,4},
                {10,6,12,8,14},
                {5,1,2,3,9},
                {5,11,12,13,9},
                {0,6,7,8,4},
                {10,6,7,8,14},
                {5,6,2,8,9},
                {5,6,12,8,9},
                {5,1,7,3,9},
                {5,11,7,13,9},
                {0,1,2,8,14},
                {10,11,12,8,4},
                {0,6,12,13,14},
                {10,6,2,3,4},
                {5,6,7,3,14},
                {5,6,7,13,4},
                {0,6,7,8,14},
                {10,6,7,8,4},
                {10,11,7,3,9},
                {0,1,7,13,9},
                {10,6,12,13,14},
                {0,6,2,3,4},
                {0,6,12,8,9},
                {10,6,2,8,9},
                {5,1,7,3,4},
                {5,11,7,13,14},
                {0,6,7,8,9},
                {10,6,7,8,9},
                {5,1,2,3,4},
                {5,11,12,13,14},
                {5,6,7,8,4},
                {5,6,7,8,14},
                {0,1,7,3,4},
                {10,11,7,13,14},
                {0,1,2,8,4},
                {10,11,12,8,14},
                {5,6,2,3,4},
                {5,6,12,13,14},
                {0,1,7,8,4},
                {10,11,7,8,14},
                {10,6,2,8,4}
        };
    }
    @Override
    public void getLinesXml(){

        if (controlType>0){
            endSlots = control();
        } else {
            endSlots = rollerXml.getLineInts( free ? 1 : 0,rollerID);
        }
        res.endSlots = endSlots.clone();
        changeWild();
    }

    public void changeWild(){
        HrljjPlayMsgs pmres = (HrljjPlayMsgs) res;
        if(free){
            pmres.setW2(1);
            pmres.setW4(1);
        }else{
            if(RandomUtil.randomInt(20) == 0 &&
                    (endSlots[1] == _WILD || endSlots[6] == _WILD || endSlots[11] ==_WILD)){
                pmres.setW2(1);
                endSlots[1] = _WILD;
                endSlots[6] = _WILD;
                endSlots[11] =_WILD;
            }
            if(RandomUtil.randomInt(20) == 0 &&
                    (endSlots[3] == _WILD || endSlots[8] == _WILD || endSlots[13] ==_WILD)){
                pmres.setW4(1);
                endSlots[3] = _WILD;
                endSlots[8] = _WILD;
                endSlots[13] =_WILD;
            }
        }
    }

    @Override
    public void freeBouns(){
        int scatterNum = fsdb(_SCATTER);
        if(scatterNum>2){
            res.setFree((byte)1);
            res.setFreeNumber(10);
        }
        int bonusNum= fsdb(_BONUS);
        if(bonusNum>2){
            res.setBouns(1);
        }
    }
    @Override
    public int[] control(){
        Controlline controlline=new Controlline();
        switch (controlType) {
            case 1:
                return bigwin();
            case 2:
                return controlline.free();
            case 3:
                return controlline.bonus();
            default:
                return controlline.empty();
        }
    }
}
